import { createRouter, createWebHashHistory } from "vue-router";
import Home from "../views/Home.vue";
export const menuList = [
  {
    path: "",
    name: "reward",
    meta: {
      linkName: "收益数据",
      iconName: "",
      index: "1",
    },
    component: () =>
      import(/* webpackChunkName: "reward" */ "../views/Reward.vue"),
  },
  {
    path: "modifyPassword",
    name: "modifyPassword",
    meta: {
      linkName: "修改密码",
      iconName: "",
      index: "2",
    },
    component: () =>
      import(/* webpackChunkName: "reward" */ "../views/ModifyPassword.vue"),
    // children:[{
    //   path:"test",
    //   name:"test",
    //   meta:{
    //     linkName:"test",
    //     iconName:"",
    //     index:"2-1"
    //   },
    //   component:()=>import(/* webpackChunkName: "reward" */"../views/test.vue"),
    // }]
  },
];
const handleRouter = (routerList, baseUrl = "/") => {
  routerList.forEach((router) => {
    router.path =
      baseUrl != "/" ? baseUrl + "/" + router.path : baseUrl + router.path;
    if (router.children) {
      handleRouter(router.children, router.path);
    }
  });
};
//处理menuList
handleRouter(menuList);
const routes = [
  {
    path: "/",
    name: "Home",
    component: Home,
    children: menuList,
  },
  {
    path: "/login",
    name: "Login",
    component: () =>
      import(/* webpackChunkName: "login" */ "../views/Login.vue"),
  },
];

const router = createRouter({
  history: createWebHashHistory(),
  routes,
});

export default router;
